import React from 'react';
import Center from './Center';
import CreateDao from './components/CreateDao';
import { getLocalStorageInfo } from '@/utils/localStorageInfo';

const DAOCenter = () => {
  // 根据DAO信息是否完善展示界面
  const [isDao, setIsDao] = React.useState(false);
  // dao信息
  const [DAOInfo, setDAOInfo] = React.useState();

  React.useEffect(() => {
    getDAOInfo();
  }, []);

  /**
   * 获取dao信息
   */
  const getDAOInfo = () => {
    let res = getLocalStorageInfo('tenantDao');
    console.log(res);
    if (res) {
      setDAOInfo(res);
      res.daoCode ? setIsDao(true) : setIsDao(false);
    }
  };
  return (
    <div>
      {!isDao ? (
        <CreateDao DAOInfo={DAOInfo} setIsDao={setIsDao} />
      ) : (
        <Center DAOInfo={DAOInfo} />
      )}
    </div>
  );
};

export default DAOCenter;
